<?php
require('connect.php');
include 'constants.php';

if (!isset($_POST['type']) || !isset($_POST['how_many']) || !isset($_POST['position']))
{
	return;
}
$type = intval($_POST['type']);
$position = $_POST['position'];
$howMany = $_POST['how_many'];
$isPuzzle = $_POST['is_puzzle'];
if($isPuzzle == "true") $isPuzzle = true; else $isPuzzle = false;

$query = "SELECT * FROM world_records WHERE type = '" . $type . "'";
$query .= getOrder($type,$isPuzzle) . " LIMIT " . $position . " , " . $howMany;

$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result))
{
	$output[] = $row;
}

echo json_encode($output);

mysql_close();